package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class OrderCollection here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 *  
 */
public class OrderCollection
{
    // Singleton
    private static OrderCollection instance;
    
    // instance variables
    private ArrayList<Order> orders;
    
    
    private OrderCollection()
    {
        orders = new ArrayList<Order>();
    }

    public static OrderCollection getInstance()
    {
        if (instance == null)
        {
            instance = new OrderCollection();
        }
        return instance;
    }
    
    public void addOrder(Order order)
    {
        orders.add(order);
    }
    
    public ArrayList<Order> findOrder(int PhoneNo)
    {
        Order order = null;
        ArrayList<Order> orderList = new ArrayList<Order>();
        
        for (Order o : orders) {
            if (o.getCustomer().getPhoneNo().equals(PhoneNo)) {
                orderList.add(o);
            }
        }
        return orderList;
    }
}
